<?php

declare(strict_types=1);

namespace app\admin\service;

use app\common\model\auth\AdminModel;
use Dengje\Pxy\BaseService;
use dengje\jwt\facade\JWTAuth;

class AccountService extends BaseService
{
    public function login($account,$password,$type)
    {
        
        $account = AdminModel::where('account',$account)->find();
        
       
        if(!$account || $account->password != encrypt_password($password,$account->salt)){
            $this->error = '用户名或密码错误';
            return false;
        }
        $token = JWTAuth::builder(['admin_id'=>$account->id]);//参数为用户认证的信息，请自行添加

        cookie('admin_id',$account->id);
        return ['token'=> $token];
    }
    
    public function getAdminInfo($admiId)
    {
        $admin = AdminModel::find($admiId);
        return $admin;
    }
}